package com.lagou.repository;

import com.lagou.pojo.Comment;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

public interface CommentRepository extends JpaRepository<Comment,Integer> {

    //根据评论id修改评论作者

    @Transactional
    @Modifying // 在@Query注解中编写jpql实现 update/delete 需要加上@Modifying 以通知jpa这是更新/删除操作
    @Query(value = "update t_comment c set c.author = ?1 where  c.id=?2",nativeQuery = true)
    public int updateComment(String author,Integer id);

}
